home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / AMAL / AMAL_6.AMOS / AMAL_6.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-28  |  4.2 KB  |  141 lines

  1. '*************************** 
  2. '*    AMOS Professional    * 
  3. '*                         * 
  4. '*         AMAL_6          *                    Synchro
  5. '*                         * 
  6. '* (c) Europress Software  * 
  7. '*                         * 
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. 'The interupt system allows a maximum of 16 Amal programs to be run at any 
  13. 'one time, with the use of Synchro this restriction is lifted by-passing 
  14. 'the interupt system and stepping through the Amal programs directly from
  15. 'Basic.
  16. 'Channel numbers can now range from 0-63 with the added bonus of collision 
  17. 'detection being possible from within your Amal program. 
  18. 'Amal strings are defined as normal but before assigning the channels the
  19. 'Synchro Off is used which turns off the interupts allowing the extra
  20. 'channels 16-63 to be used, then with each call to Synchro the Amal programs 
  21. 'will be stepped through.
  22. '
  23. '          Define Amal strings 
  24. '          Switch off interupts with Synchro Off 
  25. '          Assign Amal strings to the channels 0-63
  26. '          Amal On 
  27. '          Do
  28. '          Synchro 
  29. '          Loop
  30. '
  31. 'Interupts can be switched back on again with the Synchro On command reducing
  32. 'channel numbers back to the normal 0-15 
  33. '
  34. '------------------------------------------- 
  35. ' =BC  =SC 
  36. '------------------------------------------- 
  37. 'Amal bob and sprite collision detection 
  38. '
  39. 'These functions are only possible when interupts have been switched off with
  40. 'the Synchro Off and are identical in operation to the Bob Col & Sprite Col
  41. 'functions in AMOS Professional Basic.   
  42. '
  43. '                       +--->object number to be tested
  44. '                       |  +--->range of objects to be tested against
  45. '                       | / \
  46. '             Let R0=BC(1,5,8) 
  47. '             If SC(5,1,4) Jump Hit
  48. '
  49. 'If a collision has occured a value of -1 (True) will be returned otherwise  
  50. 'it will be 0 (False). 
  51. '
  52. '------------------------------------------- 
  53. ' =C 
  54. '------------------------------------------- 
  55. 'Amal collision status function
  56. '
  57. 'This function returns the status of an object after a BC or SC function.
  58. 'Once again this function can only be used when Synchro Off is in operation. 
  59. '
  60. '                       +--->object number to be tested
  61. '             Let R0=C(5)  
  62. '             If C(2) Jump Ouch
  63. '
  64. 'If the object has collided then -1 (True) will be returned otherwise it will
  65. 'be 0 (False).   
  66. '
  67. '------------------------------------------- 
  68. 'EXAMPLE 
  69. '------------------------------------------- 
  70. Rem *** Load the bird bobs 
  71. Load "AMOSPro_Tutorial:Objects/Amal_bobs.abk"
  72. '
  73. Rem *** tidy up the screen and double buffer 
  74. Screen Open 0,320,200,8,Lowres
  75. Curs Off : Flash Off : Cls 0 : Get Sprite Palette : Hide 
  76. Double Buffer 
  77. Paper 0 : Pen 2 : Locate 0,3 : Centre "Migration time...."
  78. Pen 4 : Locate 0,20 : Centre "Left mouse key to add some more birds"
  79. Pen 1 : Locate 0,22 : Centre "Right mouse key to quit"
  80. '
  81. Rem *** Switch off interrupts  
  82. '
  83. Synchro Off 
  84. '
  85. Rem *** Define Amal strings
  86. '
  87. A$="Anim 0,(5,2)(6,2)(7,2)(8,2);"
  88. A$=A$+"Loop: Let R0=Z(255)+Z(63)-X; Let R1=Z(127)+Z(63)-Y; Let RZ=Z(15)+4;"
  89. A$=A$+"Move R0,R1,RZ; Jump Loop"
  90. B$="Anim 0,(1,2)(2,2)(3,2)(4,2);"
  91. B$=B$+"Loop: Let R0=Z(255)+Z(63)-X; Let R1=Z(127)+Z(63)-Y; Let RZ=Z(15)+4;"
  92. B$=B$+"Move R0,R1,RZ; Jump Loop"
  93. C$="Loop:For R0=1 To 5; Pause; Next R0; Pause Jump Loop"
  94. D$="Anim 0,(5,2)(6,2)(7,2)(8,2);Move 300,0,150"
  95. E$="Anim 0,(1,2)(2,2)(3,2)(4,2);Move -300,0,150"
  96. '
  97. Rem *** assign the 63 channels   
  98. '
  99. For N=0 To 63
  100.    Bob N,800,400,1
  101.    Set Bob N,1,%111,
  102.    Channel N To Bob N
  103.    Amal N,C$
  104. Next 
  105. For N=0 To 15
  106.    If Rnd(1)=0
  107.       Amal N,A$ : Amal On N
  108.    Else 
  109.       Amal N,B$ : Amal On N
  110.    End If 
  111. Next 
  112. COUNT=16
  113. '
  114. Rem *** start the Main loop
  115. '
  116. Repeat 
  117.    If COUNT<63 and Mouse Key=1
  118.       Inc COUNT
  119.       Bob COUNT,Rnd(320)+1,Rnd(200)+1,Rnd(3)+1
  120.       If Rnd(1)=0
  121.          Amal COUNT,A$ : Amal On COUNT
  122.       Else 
  123.          Amal COUNT,B$ : Amal On COUNT
  124.       End If 
  125.    End If 
  126.    Synchro : Wait Vbl 
  127. Until Mouse Key=2
  128. Fade 8,$44F
  129. Clw : Pen 6 : Locate 0,12 : Centre "Bye,  bye,  Birdies!"
  130. For N=0 To 63
  131.    If I Bob(N)<5
  132.       Amal N,E$
  133.    Else 
  134.       Amal N,D$
  135.    End If 
  136.    Amal On N
  137. Next 
  138. For N=1 To 150
  139.    Synchro : Wait Vbl 
  140. Next 
  141. Edit